//
//  RootViewController.m
//  Doc Bao
//
//  Created by Hai Nguyen on 9/16/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "RootViewController.h"
#import "NewsHomeViewController.h"

@implementation RootViewController
@synthesize tabBarController;
@synthesize tabBarView;
@synthesize homeButton;
@synthesize newsButton;
@synthesize favoriteButton;
@synthesize settingButton;
@synthesize tabBarBGImageView;
@synthesize tabbar;

-(IBAction) tabbarButtonPressed:(id)sender{
	UIButton *button =(UIButton *)sender;
	NSLog(@"Button tag %d", button.tag);
	switch (button.tag) {
		case 1:{
			[homeButton setSelected:YES];
			[newsButton setSelected:NO];
			[favoriteButton setSelected:NO];
			[settingButton setSelected:NO];
			[tabBarController setSelectedIndex:0];
		}
			break;
		case 2:{
			[homeButton setSelected:NO];
			[newsButton setSelected:YES];
			[favoriteButton setSelected:NO];
			[settingButton setSelected:NO];
			[tabBarController setSelectedIndex:1];
		}			
			break;
		case 3:{
			[homeButton setSelected:NO];
			[newsButton setSelected:NO];
			[favoriteButton setSelected:YES];
			[settingButton setSelected:NO];
			[tabBarController setSelectedIndex:2];
		}
			
			break;
		case 4:{
			[homeButton setSelected:NO];
			[newsButton setSelected:NO];
			[favoriteButton setSelected:NO];
			[settingButton setSelected:YES];
			[tabBarController setSelectedIndex:3];
		}
			break;
		default:
			break;
	}
}

- (void) viewDidLoad{
	[super viewDidLoad];
	//tabBarController = [[UITabBarController alloc] init];
	[self.view addSubview:tabBarController.view];
	[tabBarController.view setFrame:CGRectMake(0, 0, 320, 460)];
	[self.view addSubview:tabBarView];
	[tabBarView setFrame:CGRectMake(0, 411, 320, 49)];
	NSLog(@"alala");
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
	self.tabBarController = nil;
	self.tabBarView = nil;
	self.homeButton = nil;
	self.newsButton = nil;
	self.favoriteButton = nil;
	self.settingButton = nil;
	self.tabBarBGImageView = nil;
}

- (void)dealloc {
	self.tabBarController = nil;
	[tabBarView release];
	[homeButton release];
	[newsButton release];
	[favoriteButton release];
	[settingButton release];
	[tabBarBGImageView release];
	[tabbar release];
    [super dealloc];
}

@end
